23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <com/sun/star/view/XViewSettingsSupplier.hpp>
25#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
26#include <com/sun/star/text/XText.hpp>
27#include <com/sun/star/text/XTextDocument.hpp>
28#include <com/sun/star/text/XFootnotesSupplier.hpp>
29#include <com/sun/star/text/XEndnotesSupplier.hpp>
30#include <com/sun/star/text/XPageCursor.hpp>
31#include <com/sun/star/container/XIndexAccess.hpp>
32#include <com/sun/star/frame/XController.hpp>
33#include <com/sun/star/lang/XServiceInfo.hpp>
34#include <ooo/vba/word/WdSpecialPane.hpp>
35#include <ooo/vba/word/WdViewType.hpp>
36#include <ooo/vba/word/WdSeekView.hpp>
47SwVbaView::SwVbaView(
const uno::Reference< ooo::vba::XHelperInterface >& rParent,
const uno::Reference< uno::XComponentContext >& rContext,
48 uno::Reference< frame::XModel > xModel ) :
53 uno::Reference< text::XTextViewCursorSupplier > xTextViewCursorSupp(
xController, uno::UNO_QUERY_THROW );
56 uno::Reference< view::XViewSettingsSupplier > xViewSettingSupp(
xController, uno::UNO_QUERY_THROW );
57 mxViewSettings.set( xViewSettingSupp->getViewSettings(), uno::UNO_SET_THROW );
66 bool bShowFormattingMarks =
false;
67 mxViewSettings->getPropertyValue(
"ShowNonprintingCharacters") >>= bShowFormattingMarks;
68 return bShowFormattingMarks;
81 uno::Reference< text::XText > xCurrentText =
mxViewCursor->getText();
82 uno::Reference< beans::XPropertySet > xCursorProps(
mxViewCursor, uno::UNO_QUERY_THROW );
83 uno::Reference< text::XTextContent > xTextContent;
84 while( xCursorProps->getPropertyValue(
"TextTable") >>= xTextContent )
86 xCurrentText = xTextContent->getAnchor()->getText();
87 xCursorProps.set( xCurrentText->createTextCursor(), uno::UNO_QUERY_THROW );
89 uno::Reference< lang::XServiceInfo > xServiceInfo( xCurrentText, uno::UNO_QUERY_THROW );
90 OUString aImplName = xServiceInfo->getImplementationName();
91 if ( aImplName ==
"SwXBodyText" )
93 return word::WdSeekView::wdSeekMainDocument;
95 else if ( aImplName ==
"SwXHeadFootText" )
100 return word::WdSeekView::wdSeekFirstPageHeader;
102 return word::WdSeekView::wdSeekEvenPagesHeader;
104 return word::WdSeekView::wdSeekPrimaryHeader;
109 return word::WdSeekView::wdSeekFirstPageFooter;
111 return word::WdSeekView::wdSeekEvenPagesFooter;
113 return word::WdSeekView::wdSeekPrimaryFooter;
116 else if ( aImplName ==
"SwXFootnote" )
118 if( xServiceInfo->supportsService(
"com.sun.star.text.Endnote") )
119 return word::WdSeekView::wdSeekEndnotes;
121 return word::WdSeekView::wdSeekFootnotes;
124 return word::WdSeekView::wdSeekMainDocument;
137 case word::WdSeekView::wdSeekFirstPageFooter:
138 case word::WdSeekView::wdSeekFirstPageHeader:
139 case word::WdSeekView::wdSeekCurrentPageFooter:
140 case word::WdSeekView::wdSeekCurrentPageHeader:
141 case word::WdSeekView::wdSeekPrimaryFooter:
142 case word::WdSeekView::wdSeekPrimaryHeader:
143 case word::WdSeekView::wdSeekEvenPagesFooter:
144 case word::WdSeekView::wdSeekEvenPagesHeader:
150 case word::WdSeekView::wdSeekFootnotes:
152 uno::Reference< text::XFootnotesSupplier > xFootnotesSupp(
mxModel, uno::UNO_QUERY_THROW );
153 uno::Reference< container::XIndexAccess > xFootnotes( xFootnotesSupp->getFootnotes(), uno::UNO_SET_THROW );
154 if( xFootnotes->getCount() > 0 )
156 uno::Reference< text::XText > xText( xFootnotes->getByIndex(0), uno::UNO_QUERY_THROW );
165 case word::WdSeekView::wdSeekEndnotes:
167 uno::Reference< text::XEndnotesSupplier > xEndnotesSupp(
mxModel, uno::UNO_QUERY_THROW );
168 uno::Reference< container::XIndexAccess > xEndnotes( xEndnotesSupp->getEndnotes(), uno::UNO_SET_THROW );
169 if( xEndnotes->getCount() > 0 )
171 uno::Reference< text::XText > xText( xEndnotes->getByIndex(0), uno::UNO_QUERY_THROW );
180 case word::WdSeekView::wdSeekMainDocument:
182 uno::Reference< text::XTextDocument > xTextDocument(
mxModel, uno::UNO_QUERY_THROW );
183 uno::Reference< text::XText > xText = xTextDocument->getText();
193 return word::WdSpecialPane::wdPaneNone;
205 bool bShowTableGridLine =
false;
206 mxViewSettings->getPropertyValue(
"ShowTableBoundaries") >>= bShowTableGridLine;
207 return bShowTableGridLine;
220 bool bOnlineLayout =
false;
221 mxViewSettings->getPropertyValue(
"ShowOnlineLayout") >>= bOnlineLayout;
222 return bOnlineLayout ? word::WdViewType::wdWebView : word::WdViewType::wdPrintView;
231 case word::WdViewType::wdPrintView:
232 case word::WdViewType::wdNormalView:
237 case word::WdViewType::wdWebView:
242 case word::WdViewType::wdPrintPreview:
258 OUString aPropIsShared;
259 OUString aPropBodyDistance;
264 case word::WdSeekView::wdSeekCurrentPageFooter:
265 case word::WdSeekView::wdSeekFirstPageFooter:
266 case word::WdSeekView::wdSeekPrimaryFooter:
267 case word::WdSeekView::wdSeekEvenPagesFooter:
269 aPropIsOn =
"FooterIsOn";
270 aPropIsShared =
"FooterIsShared";
271 aPropBodyDistance =
"FooterBodyDistance";
272 aPropText =
"FooterText";
275 case word::WdSeekView::wdSeekCurrentPageHeader:
276 case word::WdSeekView::wdSeekFirstPageHeader:
277 case word::WdSeekView::wdSeekPrimaryHeader:
278 case word::WdSeekView::wdSeekEvenPagesHeader:
280 aPropIsOn =
"HeaderIsOn";
281 aPropIsShared =
"HeaderIsShared";
282 aPropBodyDistance =
"HeaderBodyDistance";
283 aPropText =
"HeaderText";
288 uno::Reference< text::XPageCursor > xPageCursor(
mxViewCursor, uno::UNO_QUERY_THROW );
290 if(
nType == word::WdSeekView::wdSeekFirstPageFooter
291 ||
nType == word::WdSeekView::wdSeekFirstPageHeader )
293 xPageCursor->jumpToFirstPage();
296 uno::Reference< style::XStyle > xStyle;
297 uno::Reference< text::XText > xText;
300 case word::WdSeekView::wdSeekPrimaryFooter:
301 case word::WdSeekView::wdSeekPrimaryHeader:
302 case word::WdSeekView::wdSeekEvenPagesFooter:
303 case word::WdSeekView::wdSeekEvenPagesHeader:
314 uno::Reference< beans::XPropertySet > xCursorProps(
mxViewCursor, uno::UNO_QUERY_THROW );
315 OUString aPageStyleName;
316 xCursorProps->getPropertyValue(
"PageStyleName") >>= aPageStyleName;
317 if ( aPageStyleName ==
"First Page" )
320 bool hasNextPage =
false;
324 hasNextPage = xPageCursor->jumpToNextPage();
340 uno::Reference< beans::XPropertySet > xPageProps( xStyle, uno::UNO_QUERY_THROW );
342 xPageProps->getPropertyValue( aPropIsOn ) >>= isOn;
343 bool isShared =
false;
344 xPageProps->getPropertyValue( aPropIsShared ) >>= isShared;
347 xPageProps->setPropertyValue( aPropIsOn,
uno::Any(
true ) );
352 OUString aTempPropText = aPropText;
353 if(
nType == word::WdSeekView::wdSeekEvenPagesFooter
354 ||
nType == word::WdSeekView::wdSeekEvenPagesHeader )
356 aTempPropText +=
"Left";
360 aTempPropText +=
"Right";
362 xText.set( xPageProps->getPropertyValue( aTempPropText), uno::UNO_QUERY_THROW );
366 if(
nType == word::WdSeekView::wdSeekEvenPagesFooter
367 ||
nType == word::WdSeekView::wdSeekEvenPagesHeader )
371 xText.set( xPageProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
389uno::Sequence< OUString >
css::uno::Reference< css::frame::XModel2 > mxModel
virtual void SAL_CALL setSplitSpecial(::sal_Int32 _splitspecial) override
css::uno::Reference< css::text::XTextViewCursor > mxViewCursor
virtual ::sal_Int32 SAL_CALL getType() override
css::uno::Reference< css::frame::XModel > mxModel
virtual sal_Bool SAL_CALL getTableGridLines() override
virtual ~SwVbaView() override
css::uno::Reference< css::text::XTextRange > getHFTextRange(sal_Int32 nType)
css::uno::Reference< css::beans::XPropertySet > mxViewSettings
SwVbaView(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, css::uno::Reference< css::frame::XModel > xModel)
virtual void SAL_CALL setTableGridLines(sal_Bool _tablegridlines) override
virtual void SAL_CALL setType(::sal_Int32 _type) override
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual OUString getServiceImplName() override
virtual void SAL_CALL setSeekView(::sal_Int32 _seekview) override
void SAL_CALL setShowAll(sal_Bool bSet) override
virtual ::sal_Int32 SAL_CALL getSplitSpecial() override
sal_Bool SAL_CALL getShowAll() override
virtual ::sal_Int32 SAL_CALL getSeekView() override
Sequence< OUString > aServiceNames
bool gotoSelectedObjectAnchor(const uno::Reference< frame::XModel > &xModel)
uno::Reference< text::XTextRange > getFirstObjectPosition(const uno::Reference< text::XText > &xText)
uno::Reference< style::XStyle > getCurrentPageStyle(const uno::Reference< frame::XModel > &xModel)
SwView * getView(const uno::Reference< frame::XModel > &xModel)
void PrintPreviewHelper(const css::uno::Any &, SfxViewShell const *pViewShell)
#define ERRCODE_BASIC_NO_ACTIVE_OBJECT
#define ERRCODE_BASIC_BAD_ACTION
#define ERRCODE_BASIC_INTERNAL_ERROR
#define ERRCODE_BASIC_NOT_IMPLEMENTED
Reference< XController > xController
Reference< XModel > xModel
const sal_Int32 DEFAULT_BODY_DISTANCE