20#include <com/sun/star/frame/XModel.hpp>
21#include <com/sun/star/text/XPageCursor.hpp>
22#include <ooo/vba/word/WdSectionStart.hpp>
23#include <ooo/vba/word/WdOrientation.hpp>
30 const uno::Reference< uno::XComponentContext >& xContext,
31 const uno::Reference< frame::XModel >& xModel,
32 const uno::Reference< beans::XPropertySet >& xProps ):
36 mxPageProps.set( xProps, uno::UNO_SET_THROW );
37 mnOrientPortrait = word::WdOrientation::wdOrientPortrait;
38 mnOrientLandscape = word::WdOrientation::wdOrientLandscape;
59 bool isHeaderOn =
false;
60 mxPageProps->getPropertyValue(
"HeaderIsOn") >>= isHeaderOn;
62 mxPageProps->setPropertyValue(
"HeaderIsOn",
uno::Any(
true ) );
77 sal_Int32 newHeaderDistance = Millimeter::getInHundredthsOfOneMillimeter( _headerdistance );
78 bool isHeaderOn =
false;
79 sal_Int32 currentTopMargin = 0;
80 sal_Int32 currentSpacing = 0;
81 sal_Int32 currentHeaderHeight = 0;
83 mxPageProps->getPropertyValue(
"HeaderIsOn") >>= isHeaderOn;
85 mxPageProps->setPropertyValue(
"HeaderIsOn",
uno::Any(
true ) );
87 mxPageProps->getPropertyValue(
"TopMargin") >>= currentTopMargin;
88 mxPageProps->getPropertyValue(
"HeaderBodyDistance") >>= currentSpacing;
89 mxPageProps->getPropertyValue(
"HeaderHeight") >>= currentHeaderHeight;
91 sal_Int32 newSpacing = currentSpacing - ( newHeaderDistance - currentTopMargin );
92 sal_Int32 height = currentHeaderHeight - currentSpacing;
93 sal_Int32 newHeaderHeight = newSpacing + height;
95 mxPageProps->setPropertyValue(
"TopMargin",
uno::Any( newHeaderDistance ) );
96 mxPageProps->setPropertyValue(
"HeaderBodyDistance",
uno::Any( newSpacing ) );
97 mxPageProps->setPropertyValue(
"HeaderHeight",
uno::Any( newHeaderHeight ) );
102 bool isFooterOn =
false;
103 mxPageProps->getPropertyValue(
"FooterIsOn") >>= isFooterOn;
105 mxPageProps->setPropertyValue(
"FooterIsOn",
uno::Any(
true ) );
111 sal_Int32 newFooterDistance = Millimeter::getInHundredthsOfOneMillimeter( _footerdistance );
112 bool isFooterOn =
false;
113 sal_Int32 currentBottomMargin = 0;
114 sal_Int32 currentSpacing = 0;
115 sal_Int32 currentFooterHeight = 0;
117 mxPageProps->getPropertyValue(
"FooterIsOn") >>= isFooterOn;
119 mxPageProps->setPropertyValue(
"FooterIsOn",
uno::Any(
true ) );
121 mxPageProps->getPropertyValue(
"BottomMargin") >>= currentBottomMargin;
122 mxPageProps->getPropertyValue(
"FooterBodyDistance") >>= currentSpacing;
123 mxPageProps->getPropertyValue(
"FooterHeight") >>= currentFooterHeight;
125 sal_Int32 newSpacing = currentSpacing - ( newFooterDistance - currentBottomMargin );
126 sal_Int32 height = currentFooterHeight - currentSpacing;
127 sal_Int32 newFooterHeight = newSpacing + height;
129 mxPageProps->setPropertyValue(
"BottomMargin",
uno::Any( newFooterDistance ) );
130 mxPageProps->setPropertyValue(
"FooterBodyDistance",
uno::Any( newSpacing ) );
131 mxPageProps->setPropertyValue(
"FooterHeight",
uno::Any( newFooterHeight ) );
137 if ( pageStyle ==
"First Page" )
150 newStyle =
"First Page";
152 newStyle =
"Standard";
156 xStyleProps->getPropertyValue(
"TopMargin") >>=
nTopMargin;
158 xStyleProps->getPropertyValue(
"BottomMargin") >>=
nBottomMargin;
160 xStyleProps->getPropertyValue(
"LeftMargin") >>=
nLeftMargin;
162 xStyleProps->getPropertyValue(
"RightMargin") >>=
nRightMargin;
163 sal_Int32 nHeaderHeight = 0;
164 xStyleProps->getPropertyValue(
"HeaderHeight") >>= nHeaderHeight;
165 sal_Int32 nFooterHeight = 0;
166 xStyleProps->getPropertyValue(
"FooterHeight") >>= nFooterHeight;
168 bool isHeaderOn =
false;
169 xStyleProps->getPropertyValue(
"HeaderIsOn") >>= isHeaderOn;
174 xStyleProps->setPropertyValue(
"HeaderIsOn",
uno::Any(
false ) );
175 xStyleProps->setPropertyValue(
"FooterIsOn",
uno::Any(
false ) );
178 if( xPageCursor->getPage() != 1 )
180 xPageCursor->jumpToFirstPage();
183 uno::Reference< beans::XPropertySet > xCursorProps( xPageCursor, uno::UNO_QUERY_THROW );
184 uno::Reference< beans::XPropertySet > xTableProps( xCursorProps->getPropertyValue(
"TextTable"), uno::UNO_QUERY );
185 if( xTableProps.is() )
187 xTableProps->setPropertyValue(
"PageDescName",
uno::Any( newStyle ) );
191 xCursorProps->setPropertyValue(
"PageDescName",
uno::Any( newStyle ) );
203 OUString styleFirstPage;
205 if( xPageCursor->getPage() != 1 )
207 xPageCursor->jumpToFirstPage();
210 uno::Reference< beans::XPropertySet > xCursorProps( xPageCursor, uno::UNO_QUERY_THROW );
211 uno::Reference< beans::XPropertySet > xTableProps( xCursorProps->getPropertyValue(
"TextTable"), uno::UNO_QUERY );
212 if( xTableProps.is() )
214 xTableProps->getPropertyValue(
"PageDescName") >>= styleFirstPage;
218 xCursorProps->getPropertyValue(
"PageDescName") >>= styleFirstPage;
220 return styleFirstPage;
226 sal_Int32 wdSectionStart = word::WdSectionStart::wdSectionNewPage;
227 uno::Reference< container::XNamed > xNamed( mxPageProps, uno::UNO_QUERY_THROW );
228 OUString sStyleName = xNamed->getName();
229 if ( sStyleName ==
"Left Page" )
230 wdSectionStart = word::WdSectionStart::wdSectionEvenPage;
231 else if ( sStyleName ==
"Right Page" )
232 wdSectionStart = word::WdSectionStart::wdSectionOddPage;
234 wdSectionStart = word::WdSectionStart::wdSectionNewPage;
235 return wdSectionStart;
247 return "SwVbaPageSetup";
250uno::Sequence< OUString >
255 "ooo.vba.word.PageSetup"
css::uno::Reference< css::frame::XModel2 > mxModel
virtual double SAL_CALL getGutter() override
virtual double SAL_CALL getHeaderDistance() override
virtual void SAL_CALL setDifferentFirstPageHeaderFooter(sal_Bool status) override
virtual OUString getServiceImplName() override
virtual void SAL_CALL setFooterDistance(double _footerdistance) override
virtual ::sal_Int32 SAL_CALL getSectionStart() override
virtual sal_Bool SAL_CALL getDifferentFirstPageHeaderFooter() override
virtual void SAL_CALL setSectionStart(::sal_Int32 _sectionstart) override
OUString getStyleOfFirstPage() const
SwVbaPageSetup(const css::uno::Reference< ooo::vba::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::beans::XPropertySet > &xProps)
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual double SAL_CALL getFooterDistance() override
virtual void SAL_CALL setHeaderDistance(double _headerdistance) override
changes the value of TopMargin to the value of new MS-Word-HeaderDistance.
virtual void SAL_CALL setGutter(double _gutter) override
virtual double SAL_CALL getFooterMargin()
virtual double SAL_CALL getHeaderMargin()
virtual double SAL_CALL getLeftMargin() override
virtual void SAL_CALL setLeftMargin(double margin) override
Sequence< OUString > aServiceNames
tools::Long const nRightMargin
tools::Long const nBottomMargin
tools::Long const nTopMargin
tools::Long const nLeftMargin
uno::Reference< text::XTextViewCursor > getXTextViewCursor(const uno::Reference< frame::XModel > &xModel)
uno::Reference< style::XStyle > getCurrentPageStyle(const uno::Reference< frame::XModel > &xModel)
Reference< XModel > xModel
cppu::ImplInheritanceHelper< VbaPageSetupBase, ooo::vba::word::XPageSetup > SwVbaPageSetup_BASE