28#include <unoprnms.hxx>
31#include <rtl/string.h>
39#include <com/sun/star/frame/Desktop.hpp>
40#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
41#include <com/sun/star/view/XScreenCursor.hpp>
42#include <com/sun/star/view/DocumentZoomType.hpp>
43#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
44#include <com/sun/star/style/XStyle.hpp>
45#include <com/sun/star/text/XTextDocument.hpp>
46#include <com/sun/star/awt/PosSize.hpp>
47#include <com/sun/star/view/XViewSettingsSupplier.hpp>
48#include <com/sun/star/container/XNameContainer.hpp>
49#include <com/sun/star/frame/XLayoutManager.hpp>
63constexpr OUStringLiteral
cFactory =
u"private:factory/swriter";
66 bool bEnableOnlineMode)
84 if (bEnableOnlineMode)
93 : m_aLoadedIdle(
"sw uibase SwOneExampleFrame Loaded")
94 , m_pModuleView(
SW_MOD()->GetView())
95 , m_nStyleFlags(nFlags)
96 , m_bIsInitialized(false)
98 if (pURL && !pURL->isEmpty())
101 if( pInitializedLink )
111 CustomWidgetController::SetDrawingArea(pDrawingArea);
123 case CommandEventId::ContextMenu:
133 return CustomWidgetController::Command(rCEvt);
143 Color aBgColor =
SW_MOD()->GetColorConfig().GetColorValue(::svtools::DOCCOLOR).nColor;
146 auto pCursor =
dynamic_cast<OTextCursorHelper*
>(
m_xCursor.get());
149 uno::Reference<view::XViewSettingsSupplier> xSettings(
m_xController, uno::UNO_QUERY);
150 uno::Reference<beans::XPropertySet> xViewProps = xSettings->getViewSettings();
152 sal_Int16 nZoom = 100;
155 double fZoom = 100.0 / nZoom;
159 SwDoc *pDoc = pCursor->GetDoc();
183 uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext());
185 {
"DocumentService",
uno::Any(OUString(
"com.sun.star.text.TextDocument")) },
186 {
"OpenFlags",
uno::Any(OUString(
"-RB")) },
187 {
"Referer",
uno::Any(OUString(
"private:user")) },
192 m_xModel.set(xDesktop->loadComponentFromURL(sTempURL,
"_blank", 0,
args), uno::UNO_QUERY);
214 m_xController =
m_xModel->getCurrentController();
216 if (m_xController.is())
218 uno::Reference<frame::XFrame>
xFrame = m_xController->getFrame();
219 uno::Reference< beans::XPropertySet > xPropSet(
xFrame, uno::UNO_QUERY );
224 uno::Reference< frame::XLayoutManager > xLayoutManager;
225 uno::Any aValue = xPropSet->getPropertyValue(
"LayoutManager");
226 aValue >>= xLayoutManager;
227 if ( xLayoutManager.is() )
228 xLayoutManager->setVisible(
false );
230 catch (
const uno::Exception&)
236 uno::Reference< view::XViewSettingsSupplier > xSettings(m_xController, uno::UNO_QUERY);
237 uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings();
242 if( !m_bIsInitialized )
263 aZoom <<= sal_Int16(view::DocumentZoomType::PAGE_WIDTH_EXACT);
269 aZoom <<= sal_Int16(view::DocumentZoomType::BY_VALUE);
272 sal_Int16 nZoomValue = 75;
277 aZoom <<= nZoomValue;
283 m_bIsInitialized =
true;
286 uno::Reference< text::XTextDocument > xDoc(
m_xModel, uno::UNO_QUERY);
287 uno::Reference< text::XText > xText = xDoc->getText();
288 m_xCursor = xText->createTextCursor();
293 auto pCursor =
dynamic_cast<OTextCursorHelper*
>(m_xCursor.get());
295 SwDoc *pDoc = pCursor ? pCursor->GetDoc() :
nullptr;
338 for (
auto eType : eTypes)
343 for (
auto pMark : aMarks)
345 if (pMark->GetAlternativeText() ==
"Chapter")
346 pMark->SetAlternativeText(
SwResId(STR_IDXEXAMPLE_IDXMARK_CHAPTER));
347 else if (pMark->GetAlternativeText() ==
"Keyword")
348 pMark->SetAlternativeText(
SwResId(STR_IDXEXAMPLE_IDXMARK_KEYWORD));
349 else if (pMark->GetAlternativeText() ==
"this")
350 pMark->SetAlternativeText(
SwResId(STR_IDXEXAMPLE_IDXMARK_THIS));
351 else if (pMark->GetAlternativeText() ==
"User Directory Entry")
352 pMark->SetAlternativeText(
SwResId(STR_IDXEXAMPLE_IDXMARK_USER_DIR_ENTRY));
353 else if (pMark->GetAlternativeText() ==
"Entry")
354 pMark->SetAlternativeText(
SwResId(STR_IDXEXAMPLE_IDXMARK_ENTRY));
356 if (pMark->GetPrimaryKey() ==
"Primary key")
357 pMark->SetPrimaryKey(
SwResId(STR_IDXEXAMPLE_IDXMARK_PRIMARY_KEY));
359 if (pMark->GetSecondaryKey() ==
"Secondary key")
360 pMark->SetSecondaryKey(
SwResId(STR_IDXEXAMPLE_IDXMARK_SECONDARY_KEY));
365 uno::Reference< beans::XPropertySet > xCursorProp(m_xCursor, uno::UNO_QUERY);
368 aPageStyle >>= sPageStyle;
370 uno::Reference< style::XStyleFamiliesSupplier > xSSupp( xDoc, uno::UNO_QUERY);
371 uno::Reference< container::XNameAccess > xStyles = xSSupp->getStyleFamilies();
372 uno::Any aPFamily = xStyles->getByName(
"PageStyles" );
373 uno::Reference< container::XNameContainer > xPFamily;
376 && (aPFamily >>= xPFamily) && !sPageStyle.isEmpty() )
378 uno::Any aPStyle = xPFamily->getByName( sPageStyle );
379 uno::Reference< style::XStyle > xPStyle;
381 uno::Reference< beans::XPropertySet > xPProp(xPStyle, uno::UNO_QUERY);
386 aPSize.Width = 10000;
390 uno::Any aZero; aZero <<= sal_Int32(0);
395 uno::Reference<awt::XWindow> xWin =
xFrame->getContainerWindow();
396 Size aWinSize(GetOutputSizePixel());
397 xWin->setPosSize(0, 0, aWinSize.
Width(), aWinSize.
Height(), awt::PosSize::SIZE);
402 m_aInitializedLink.Call(*
this);
404 uno::Reference< text::XTextViewCursorSupplier > xCursorSupp(m_xController, uno::UNO_QUERY);
405 uno::Reference< view::XScreenCursor > xScrCursor(xCursorSupp->getViewCursor(), uno::UNO_QUERY);
407 xScrCursor->screenUp();
419 SW_MOD()->SetView(m_pModuleView);
431 OTextCursorHelper* pCursor =
dynamic_cast<OTextCursorHelper*
>(
m_xCursor.get());
434 SwDoc* pDoc = pCursor->GetDoc();
464 std::unique_ptr<weld::Menu> xPop(xBuilder->weld_menu(
"previewmenu"));
466 uno::Reference< view::XViewSettingsSupplier > xSettings(
m_xController, uno::UNO_QUERY);
467 uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings();
473 for (
auto const nZoomPreset : { 20, 40, 50, 75, 100 })
477 OUString sIdent =
"zoom" + OUString::number(nZoomPreset);
478 xPop->set_label(sIdent, sTemp);
479 if (nZoom == nZoomPreset)
480 xPop->set_active(sIdent,
true);
490 std::u16string_view sZoomValue;
494 uno::Reference< view::XViewSettingsSupplier > xSettings(
m_xController, uno::UNO_QUERY);
495 uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings();
500 aZoom <<= sal_Int16(view::DocumentZoomType::BY_VALUE);
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
virtual void Start(bool bStartTimer=true) override
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
void DoDraw(OutputDevice *, const Point &rObjPos, const Size &rSize, const JobSetup &rSetup, sal_uInt16 nAspect=ASPECT_CONTENT, bool bOutputForScreen=false)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
bool Right(sal_uInt16 nCnt, SwCursorSkipMode nMode, bool bAllowVisual=false)
virtual void SetVisArea(const tools::Rectangle &rRect) override
OLE-stuff.
SwEditShell const * GetEditShell() const
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
SwDocShell * GetDocShell()
void StartAllAction()
For all views of this document.
void Overwrite(const OUString &)
OUString GetCurWord() const
request current word
virtual bool Command(const CommandEvent &rCEvt) override
SAL_DLLPRIVATE void CreateControl()
css::uno::Reference< css::text::XTextCursor > m_xCursor
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
bool CreatePopup(const Point &rPt)
virtual ~SwOneExampleFrame() override
css::uno::Reference< css::frame::XController > m_xController
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
ScopedVclPtr< VirtualDevice > m_xVirDev
SAL_DLLPRIVATE void DisposeControl()
Link< SwOneExampleFrame &, void > m_aInitializedLink
SwOneExampleFrame(sal_uInt32 nStyleFlags, const Link< SwOneExampleFrame &, void > *pInitializedLink, const OUString *pURL=nullptr)
void PopupHdl(std::u16string_view rId)
css::uno::Reference< css::frame::XModel > m_xModel
void CollectTextMarks(SwTOXMarks &rMarks) const
sal_uInt16 ActionCount() const
void UnlockPaint(bool bVirDev=false)
void LockPaint(LockPaintReason eReason)
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
static OUString formatPercent(double dNumber, const LanguageTag &rLangTag)
Reference< frame::XModel > m_xModel
#define LINK(Instance, Class, Member)
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
Reference< XFrame > xFrame
OUString SwResId(TranslateId aId)
std::vector< SwTOXMark * > SwTOXMarks
constexpr OUStringLiteral UNO_NAME_SIZE
constexpr OUStringLiteral UNO_NAME_RIGHT_MARGIN
constexpr OUStringLiteral UNO_NAME_SHOW_HIDDEN_PARAGRAPHS
constexpr OUStringLiteral UNO_NAME_SHOW_TABLES
constexpr OUStringLiteral UNO_NAME_SHOW_HORI_RULER
constexpr OUStringLiteral UNO_NAME_SHOW_VERT_SCROLL_BAR
constexpr OUStringLiteral UNO_NAME_ZOOM_TYPE
constexpr OUStringLiteral UNO_NAME_LEFT_MARGIN
constexpr OUStringLiteral UNO_NAME_SHOW_PARA_BREAKS
constexpr OUStringLiteral UNO_NAME_SHOW_HORI_SCROLL_BAR
constexpr OUStringLiteral UNO_NAME_SHOW_ONLINE_LAYOUT
constexpr OUStringLiteral UNO_NAME_SHOW_FIELD_COMMANDS
constexpr OUStringLiteral UNO_NAME_SHOW_GRAPHICS
constexpr OUStringLiteral UNO_NAME_PAGE_STYLE_NAME
constexpr OUStringLiteral UNO_NAME_SHOW_BREAKS
constexpr OUStringLiteral UNO_NAME_SHOW_HIDDEN_TEXT
constexpr OUStringLiteral UNO_NAME_SHOW_TABSTOPS
constexpr OUStringLiteral UNO_NAME_SHOW_SPACES
constexpr OUStringLiteral UNO_NAME_SHOW_SOFT_HYPHENS
constexpr OUStringLiteral UNO_NAME_ZOOM_VALUE
constexpr OUStringLiteral UNO_NAME_SHOW_PROTECTED_SPACES
constexpr OUStringLiteral UNO_NAME_SHOW_DRAWINGS
constexpr OUStringLiteral UNO_NAME_SHOW_VERT_RULER
constexpr OUStringLiteral UNO_NAME_HIDE_WHITESPACE